#include "../Header Files/CAnimationManager.h"

void CAnimationManager::AddAnimation( CAnimation *_pAnimation )
{
	m_vAnimList.push_back( _pAnimation );
}
void CAnimationManager::RemoveAnimation( int _nIndex )
{
	if( _nIndex < (int)m_vAnimList.size() )
		m_vAnimList.erase(m_vAnimList.begin() + _nIndex, m_vAnimList.begin() + _nIndex + 1);
}
void CAnimationManager::StartAnimation( int _nIndex )
{
	if( _nIndex < (int)m_vAnimList.size() )
		m_vAnimList[_nIndex]->SetIsPlaying(true);
}
void CAnimationManager::StopAnimation( int _nIndex )
{
	if( _nIndex < (int)m_vAnimList.size() )
		m_vAnimList[_nIndex]->SetIsPlaying(false);
}
void CAnimationManager::ClearAnimations()
{
	m_vAnimList.clear();
}
void CAnimationManager::ResetAnimation( int _nIndex )
{
	if( _nIndex < (int)m_vAnimList.size() )
		m_vAnimList[_nIndex]->Reset();
}
void CAnimationManager::Update( float _fDt )
{
	for( unsigned int i = 0; i < m_vAnimList.size(); ++i )
	{
		m_vAnimList[i]->Update( _fDt );
	}
}
void CAnimationManager::Render( void )
{
	for( unsigned int i = 0; i < m_vAnimList.size(); ++i )
	{
		m_vAnimList[i]->Render();
	}
}
bool CAnimationManager::GetIsPlaying( int _nIndex )
{
	if( _nIndex < (int)m_vAnimList.size() )
		return m_vAnimList[_nIndex]->IsPlaying();

	return false;
}
CAnimationManager::~CAnimationManager()
{
	for(unsigned int i = 0; i < m_vAnimList.size(); ++i )
	{
		delete m_vAnimList[i];
	}
}